<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org"
      xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head th:include="include :: header"></head>
<body class="hold-transition skin-blue sidebar-mini">

<section class="content-header">
    <h1>机加厂装配剩余任务量</h1>
</section>
<section class="content">
    <div class="row">
        <div class="col-xs-12">
            <div class="box">
                <div class="box-header">
                    <form id="queryForm" onsubmit="return false;">
                        <div class="row">
                            <div class="form-inline">
                                <div class="form-group">
                                    <label for="query-special">装配类型</label>
                                    <select id="query-special" class="form-control" name="special">
                                        <option value="">请选择</option>
                                        <option value="机械" th:selected="${special == '机械'}">机械装配</option>
                                        <option value="流体" th:selected="${special == '流体'}">流体装配</option>
                                    </select>
                                </div>
                                <div class="form-group">
                                    <label for="query-prodNo">生产令号</label>
                                    <input id="query-prodNo" type="text" name="prodNo" class="form-control"
                                           placeholder="请输入生产令号">
                                </div>
                                <div class="form-group">
                                    <label for="query-proName">项目名称</label>
                                    <input id="query-proName" type="text" name="proName" class="form-control"
                                           placeholder="请输入项目名称">
                                </div>
                                <div class="form-group">
                                    <label for="query-part">部分</label>
                                    <input id="query-part" type="text" name="part" class="form-control"
                                           placeholder="请输入部分">
                                </div>
                                <div class="form-group">
                                    <label for="query-drawNo">图号</label>
                                    <input id="query-drawNo" type="text" name="drawNo" class="form-control"
                                           placeholder="请输入图号">
                                </div>
                                <div class="form-group">
                                    <label for="query-drawName">图名</label>
                                    <input id="query-drawName" type="text" name="drawName" class="form-control"
                                           placeholder="请输入图名">
                                </div>
                                <button type="button" class="btn btn-success" id="btn-search"
                                        onclick="js.table.search(table)">
                                    <span class="Bold">搜索</span>
                                </button>
                            </div>
                        </div>
                    </form>
                </div>
                <div class="box-body">
                    <table id="bootstrap-table"></table>
                </div>
            </div>
        </div>
    </div>
</section>
<div th:include="include :: footer"></div>
<script th:inline="javascript">

    let table;

    $(function () {

        table = js.table.init({
            url: ctx + "overview/macTaskList",
            showExport: false,
            detailView: true,
            onExpandRow: function (index, row, $detail) {
                initChildTable(index, row, $detail);
            },
            columns: [
                {
                    title: '序号', field: 'id', width: '50',
                    formatter: function (value, row, index) {
                        return index + 1;
                    }
                },
                {title: "生产令号", field: 'prodNo'},
                {
                    title: "订单数量", field: 'proNum',
                    formatter: function (value, row) {
                        return row.proNum + row.proUnit;
                    }
                },
                {title: "项目名称", field: 'proName'},
                {title: "类型", field: 'special'},
                {title: "部分", field: 'part'},
                {title: "装配图号", field: 'drawNo'},
                {title: "装配名称", field: 'drawName'},
                {title: "装配数量", field: 'drawNum'},
                {title: "要求完成时间", field: 'compTime'},
            ]
        });
    });

    initChildTable = function (index, row, $detail) {
        let childTable = $detail.html('<table style="table-layout:fixed"></table>').find('table');
        $(childTable).bootstrapTable({
            url: ctx + "overview/macTaskRouteList",
            method: 'post',
            sidePagination: "server",
            contentType: "application/x-www-form-urlencoded",
            queryParams: {
                sheetId: row.id,
            },
            responseHandler: function (res) {
                if (res.type === "SUCCESS") {
                    return res.data;
                }
                js.modal.warning(res.msg);
                return {rows: [], total: 0};
            },
            columns: [
                {
                    title: '序号', width: '50',
                    formatter: function (value, row, index) {
                        return index + 1;
                    }
                },
                {
                    field: 'orderNo',
                    title: '路线序号'
                },
                {
                    field: 'route',
                    title: '路线名称'
                },
                {
                    field: 'recNum',
                    title: '接收数量'
                },
                {
                    field: 'applyNum',
                    title: '申请质检数量'
                },
                {
                    field: 'checkNum',
                    title: '质检数量'
                },
                {
                    field: 'status',
                    title: '转序状态',
                    formatter: function (value) {
                        if (value == 1) {
                            return '<span class="badge label-inverse">未开始</span>';
                        } else if (value == 2) {
                            return '<span class="badge label-warning">执行中</span>';
                        } else if (value == 3) {
                            return '<span class="badge label-warning">部分转序</span>';
                        } else {
                            return '<span class="badge label-success">全部转序</span>';
                        }
                    }
                }
            ]
        });
    };
</script>
</body>
</html>
